<template>
    <el-dialog
      :title="title"
      :close-on-click-modal="false"
      :visible.sync="visible"
      :before-close="cancel"
      class="JNPF-dialog JNPF-dialog_center"
      lock-scroll
      width="55%"
    >
      <el-row :gutter="15" class="">
        <el-form
          ref="elForm"
          :model="dataForm"
          :rules="rules"
          label-width="100px"
        >

        <el-col :span="12">
            <el-form-item label="所属校区">
              <el-select v-model="dataForm.FHOME" placeholder="请选择">
                <el-option
                  v-for="item in options6"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="所属学院">
              <el-select v-model="dataForm.FHOME" placeholder="请选择">
                <el-option
                  v-for="item in options5"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="学年届" class="required" prop="FYEAR">
              <el-input
                v-model="dataForm.FYEAR"
                placeholder="请输入"
                clearable
                maxlength="8"
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="所属专业">
              <el-select v-model="dataForm.FSTUDNO" placeholder="请选择">
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

         <el-col :span="12">
            <el-form-item label="所属年级">
              <el-select v-model="dataForm.FPARENTNO" placeholder="请选择">
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="绑定场地">
              <el-select v-model="dataForm.FPOINTNO" placeholder="请选择">
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="班级编号" class="required" prop="FCATNO">
              <el-input
                v-model="dataForm.FCATNO"
                placeholder="请输入"
                clearable
                :disabled="!insertorupdate"
                maxlength="8"
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="班主任">
              <el-select v-model="dataForm.FTEACH" placeholder="请选择">
                <el-option
                  v-for="item in options4"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item class="required" label="班级名称" prop="FCATNAME">
              <el-input
                v-model="dataForm.FCATNAME"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="是否显示">
              <el-radio-group v-model="dataForm.FVISIBLE">
                <el-radio :label="1">否</el-radio>
                <el-radio :label="2">是</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>

          <el-col :span="12">
          <el-form-item label="有效起日" prop="FBEGDATE" >
            <el-date-picker v-model="dataForm.FBEGDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
         </el-col>

        <el-col :span="12">
          <el-form-item label="有效讫日" prop="FENDDATE" >
            <el-date-picker v-model="dataForm.FENDDATE" value-format="yyyy-MM-DD" type="date" placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>

          <el-col :span="24">
            <el-form-item label="班级格言">
              <el-input
                type="textarea"
                :autosize="{ minRows: 2, maxRows: 4}"
                v-model="dataForm.FNOTE"
                placeholder="请输入"
                clearable
                :style="{ width: '100%' }"
              >
              </el-input>
            </el-form-item>
          </el-col>

        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="cancel">取 消</el-button>
        <el-button  v-if="insertorupdate" type="primary" v-loading="loading">确 定</el-button>
        <el-button v-else type="primary"  v-loading="loading">修 改</el-button>
      </span>
    </el-dialog>
  </template>
  <script>
  import jnpf from "@/utils/jnpf"
  export default {
    props: {
      parelist: {
        type: Array,
        default: []
      },
    },
    data() {
      return {
          title:"新增",
          dataForm:{
            FHOME:"奉贤海湾校区",
            FPARENTNO: "大一",
            FCATNO: "1001",
            FCATNAME: "24级化学系1班",
            FPOINTNO: "奉1教楼101",
            FSTUDNO: "化学系",
            FTEACH: "秦始皇",
            FNOTE: "第一还看我",
            FMEMO: "",
            FVISIBLE: 1,
            FBEGDATE:"2024-10-01",
            FENDDATE:"2028-06-30",
            FOPERATOR: "system",
            FUPDDATE: "2011-02-16T02:57:02.000+00:00"
          },
          rules: {
            FCATNO: [
                  { required: true, message: '请输入班级编号', trigger: 'blur' },
              ],
              FCATNAME: [
                  { required: true, message: '请输入班级名称', trigger: 'blur' },
              ],
              FYEAR:[
                  { required: true, message: '请输入学年届', trigger: 'blur' },
              ],
          },
        fvisiblelist:[
          {id:"1",fullName:"是"},
          {id:"2",fullName:"否"},
        ],
        //所属校区选择数据
        options1: [{
          value: 'L001',
          label: '大一'
        }, {
          value: 'L002',
          label: '大二'
        }, {
          value: 'L003',
          label: '大三'
        }, {
          value: 'L004',
          label: '大四'
        }],

        //所属场地选择数据
        options2: [{
          value: 'L001',
          label: '奉1教楼101'
        }, {
          value: 'L002',
          label: '奉1教楼102'
        }, {
          value: 'L003',
          label: '奉1教楼103'
        }, {
          value: 'L004',
          label: '奉1教楼104'
        }],

        //所属专业选择数据
        options3: [{
          value: 'L001',
          label: '化学系'
        }, {
          value: 'L002',
          label: '化工与材料系'
        }, {
          value: 'L003',
          label: '生物科学'
        }, {
          value: 'L004',
          label: '食品安全与检测'
        }],

        //班主任选择数据
        options4: [{
          value: 'L001',
          label: '秦始皇'
        }, {
          value: 'L002',
          label: '汉武帝'
        }, {
          value: 'L003',
          label: '唐太宗'
        }, {
          value: 'L004',
          label: '宋太祖'
        }],

        options5: [{
          value: 'L001',
          label: '化学与材料科学学院'
        }, {
          value: 'L002',
          label: '生命科学学院'
        }],

        options6: [{
          value: '10',
          label: '徐汇桂林路校区'
        }, {
          value: '20',
          label: '奉贤海湾校区'
        }],

        loading:false,
        visible:false,
        insertorupdate:true
      };
    },
    created() {
    },
    mounted() {},
    methods: {
      //
      init(id){
        this.dataForm.FCATNO= id || ''
          if(this.dataForm.FCATNO)
          {
              this.title="修改"
             this.insertorupdate=false;
          }
          else
          {
            this.insertorupdate=true;
              this.title="新增";
          }
          this.visible=true;
      },
      //
      cancel(){
          this.$refs.elForm.resetFields();
          this.visible=false;
      },
    },
  };
  </script>
  
  
  
  
  